<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:sc="http://www.springframework.org/schema/security" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

	<bean id="passwordEncoder"
		class="org.springframework.security.authentication.encoding.ShaPasswordEncoder">
		<constructor-arg value="256" />
	</bean>

	<sc:http use-expressions="true">
		<sc:intercept-url pattern="/module/*" access="hasRole('ADMINISTRATOR')" />
		<sc:intercept-url pattern="/security/*" access="hasRole('ADMINISTRATOR')" />
		<sc:intercept-url pattern="/home" access="hasRole('ADMINISTRATOR')" />

		<sc:form-login login-page="/" default-target-url="/home"
			login-processing-url="/login" username-parameter="username"
			password-parameter="password" authentication-failure-url="/?failure" />
		<sc:logout logout-url="/logout" logout-success-url="/"
			invalidate-session="true" />
	</sc:http>

	<!-- <sc:authentication-manager> -->
	<!-- <sc:authentication-provider> -->
	<!-- <sc:user-service> -->
	<!-- <sc:user name="admin" password="admin" authorities="ADMINISTRATOR" 
		/> -->
	<!-- </sc:user-service> -->
	<!-- </sc:authentication-provider> -->
	<!-- </sc:authentication-manager> -->

	<bean id="userService" class="org.meruvian.yama.security.UserService" />

	<!-- Database authentication -->
	<sc:authentication-manager>
		<sc:authentication-provider user-service-ref="userService">
			<sc:password-encoder ref="passwordEncoder" />
		</sc:authentication-provider>
	</sc:authentication-manager>
</beans>
